package com.lcf.framework.p6spy;

import com.p6spy.engine.spy.appender.MessageFormattingStrategy;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 描述：p6spy日志格式化
 *
 * @author lcf
 * @since 2025/3/9 14:00
 */
public class P6spyMessageFormattingStrategy implements MessageFormattingStrategy {
    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");

    @Override
    public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) {
        return "执行时间: " + DATE_FORMAT.format(new Date()) + " | 执行耗时: " + elapsed + "ms | 执行语句: "  + sql;
    }
}
